<#include "layout/template.ftl"/>

<@htmlHead title="编辑用户">
   	<link href="${resources}/plugins/bootstrap-datetimepicker/2.3.4/css/bootstrap-datetimepicker.min.css" rel="stylesheet" />
</@htmlHead>


<@htmlBody 'system' 'userManage'>

	<!-- breadcrumbs begin -->
	<#include "layout/breadcrumbs.ftl">
	<@breadcrumbs '用户管理' '编辑用户信息'></@breadcrumbs>
	<!-- breadcrumbs end -->

	<!-- page-content begin -->
	<div class="page-content">
			
		<!-- page-header begin -->
		<div class="page-header">
			<h1>
				编辑用户
			</h1>
		</div>
		<!-- page-header end -->

		<!-- row begin -->
		<div class="row">
			<!-- col begin -->
			<div class="col-md-10 col-md-offset-1">
				<!-- alert:提示信息 begin -->
				<div class="alert alert-success no-margin">
					<button type="button" class="close" data-dismiss="alert">
						<i class="ace-icon fa fa-times"></i>
					</button>
					<i class="ace-icon fa fa-umbrella bigger-120 blue"></i>
					点击下图或概要文件字段编辑它们
				</div>
				<!-- end:提示信息 begin -->
				
				<!-- form begin -->
				<form  class="form-horizontal" id="validation-form"  method="post" action="${path}/manage/system/user/update/${user.id}">
					<input type="hidden" id="id" name="id"  value="${user.id}">
				
					<!-- edit-basic: 编辑信息面板 begin -->
					<div id="edit-basic" class="" style="border: 1px solid #98DAF0;padding: 0px 15px;margin-top: 10px;">
						<!-- 基本信息 begin-->
						<h4 class="header blue bolder smaller">基本信息</h4>
						
						
						<!-- 用户名 begin -->
						<div class="form-group">
							<label class="col-md-3 control-label no-padding-right" for="username">用户名</label>
							<div class="col-md-9">
								<div class="clearfix">
								<input class="input-xlarge" type="text" readonly id="username" name="username" placeholder="请输入用户名" value="${user.username}">
								</div>
							</div>
						</div>
						
						<!-- 密码 begin -->
						<div class="space-4"></div>
						<div class="form-group">
							<label class="col-md-3 control-label no-padding-right" for="password">密码</label>
							<div class="col-md-9">
								<div class="clearfix">
								<input class="input-xlarge" type="password" readonly id="password" name="password" placeholder="请输入密码" value="${user.password}">
								</div>
							</div>
						</div>
						
						<div class="space-4"></div>
						<div class="form-group">
							<label class="col-md-3 control-label no-padding-right" for="name">角色</label>

							<div class="col-md-9">
								<div class="clearfix">
									<#list  roleList as allrole>
										<#assign flag=false>
										<#if allrole.status ==1>		
										<#list user.roleList as role>
											<#if allrole.id==role.id>	
												<#assign flag=true>	
											</#if>		
										</#list>
										<label class="checkbox-inline" <#if allrole.id==1 >style="display:none;"</#if>  >
                        			 		<input name="myRoleList"   value="${allrole.id}"  type="checkbox"  ${flag?string('checked','')} >${allrole.name}
										</label>
										</#if>
									</#list>
								</div>
							</div>
						</div>
						
					</div>
					<!-- edit-basic: 编辑信息面板 end -->
					
					<div class="clearfix form-actions">
						<div class="col-md-offset-3 col-md-9">
							<button class="btn btn-info" type="submit">
								<i class="ace-icon fa fa-check bigger-110"></i>
								保存
							</button>

							&nbsp; &nbsp;
							<button class="btn" type="reset">
								<i class="ace-icon fa fa-undo bigger-110"></i>
								 重置
							</button>
						</div>
					</div>
					
				</form>
				<!-- /form end -->
				
			</div>
			<!-- /col end -->	
		</div>
		<!-- /row end -->	
		
	</div>		
	<!-- page-content end -->

</@htmlBody>



<@htmlBodyScript>
	<!-- 日期控件-->
 	<script src="${resources}/plugins/bootstrap-datetimepicker/2.3.4/js/bootstrap-datetimepicker.js"></script>
   <script src="${resources}/plugins/bootstrap-datetimepicker/2.3.4/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>
	<script>
		$("#birthday").datetimepicker({
			bootcssVer:3,
		    format: "yyyy-mm-dd",
		    language:"zh-CN",
			weekStart: 1,
        	todayBtn:  1,
			autoclose: 1,
			todayHighlight: 1,
			startView: 2,
			minView: 2,
			forceParse: 0
		});
	</script>
	
	<!-- 验证框架 -->	
	<script src="${resources}/plugins/jquery-validation/jquery.validate.min.js"></script>
	<script src="${resources}/plugins/jquery-validation/messages_zh.min.js"></script>
	<script type="text/javascript">

			jQuery.validator.addMethod("isName", function(value, element) {       
	 			var corpName =  /^[\u0391-\uFFE5\w\-\s\.]{1,50}$/;
  				 return this.optional(element) || corpName.test(value);       
 			}, "请使用汉字、英文字母、数字、下划线、减号、空格或点");   
 			
	
			$('#validation-form').validate({
				errorElement: 'div',
				errorClass: 'help-block',
				focusInvalid: false,
				rules: {
					username: {
						required:true,
						maxlength: 50
					},
					password: {
						required: true,
						minlength: 6,
						maxlength:32
					}
				},
				messages: {
					username:{
						remote:"账户名称重复"
					},
					password: {
						required: "<span>*</span>请输入密码",
						minlength: "<span>*</span>密码不能少于6个字符",
						maxlength: "<span>*</span>密码不能超过32个字符"
				   	},
				},
		
		
				highlight: function (e) {
					$(e).closest('.form-group').removeClass('has-info').addClass('has-error');
				},
		
				success: function (e) {
					$(e).closest('.form-group').removeClass('has-error');//.addClass('has-info');
					$(e).remove();
				},
		
				errorPlacement: function (error, element) {
					if(element.is('input[type=checkbox]') || element.is('input[type=radio]')) {
						var controls = element.closest('div[class*="col-"]');
						if(controls.find(':checkbox,:radio').length > 1) controls.append(error);
						else error.insertAfter(element.nextAll('.lbl:eq(0)').eq(0));
					}
					else if(element.is('.select2')) {
						error.insertAfter(element.siblings('[class*="select2-container"]:eq(0)'));
					}
					else if(element.is('.chosen-select')) {
						error.insertAfter(element.siblings('[class*="chosen-container"]:eq(0)'));
					}
					else error.insertAfter(element.parent());
				},
		
				submitHandler: function (form) {
					form.submit();
				},
				invalidHandler: function (form) {
				}
			});
	</script>
</@htmlBodyScript>